﻿#ifndef LIBRARY_H
#define LIBRARY_H

#include <QObject>
#include <QFile>
#include <QMutexLocker>
#include <QMutex>
#include <QHash>
#include <QList>
#include <QTimer>

#include "qtredis.h"
#include "downloadmq.h"


#include <iostream>
using namespace std;

class Library : public QObject
{
    Q_OBJECT
public:
    static Library* getInstance();
    CFile get(QString path);
    CFile get(QString path,int start,int end);
private:
    Library();
    //路径数据库
    static QtRedis* redis;
    //下载队列
    DownloadMQ *mq = nullptr;
    //单例
    static Library* instance;
    //单例锁
    static QMutex mutex;
    //保存需求性较高的文件
    QHash<QString,CFile> file_library;
    //保存断点下载的文件
    QHash<QString ,CFile> download_library;
};

#endif // LIBRARY_H
